package com.boge.modules.shop.controller;

import java.util.Arrays;
import java.util.Map;

import com.boge.common.utils.ShiroUtils;
import com.boge.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.boge.modules.shop.entity.CollectEntity;
import com.boge.modules.shop.service.CollectService;
import com.boge.common.utils.PageUtils;
import com.boge.common.utils.R;



/**
 * 
 *
 * @author boge
 * @email dengpbs@163.com
 * @date 2025-01-13 19:39:56
 */
@RestController
@RequestMapping("shop/collect")
public class CollectController {
    @Autowired
    private CollectService collectService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("shop:collect:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = collectService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("shop:collect:info")
    public R info(@PathVariable("id") Integer id){


        CollectEntity collect = collectService.getById(id);

        return R.ok().put("collect", collect);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("shop:collect:save")
    public R save(@RequestBody CollectEntity collect){
        SysUserEntity userEntity = ShiroUtils.getUserEntity();
        collect.setUserId(userEntity.getUserId().intValue());
		collectService.save(collect);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("shop:collect:update")
    public R update(@RequestBody CollectEntity collect){
		collectService.updateById(collect);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("shop:collect:delete")
    public R delete(@RequestParam Integer id){
		collectService.removeById(id);

        return R.ok();
    }

}
